using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using JGSY.CMS.LowCode.Platform.Infrastructure.Configuration.ServiceModules;

namespace JGSY.CMS.LowCode.Platform.Infrastructure.Configuration.MiddlewareModules.Modules
{
    /// <summary>
    /// 路由中间件模块
    /// 包含控制器路由映射
    /// </summary>
    public class RoutingMiddlewareModule : IMiddlewareModule
    {
        public string ModuleName => "路由中间件";
        public int Priority => 5; // 在认证授权之后，系统优化之前
        public bool EnableInDevelopment => true;
        public bool EnableInProduction => true;
        public bool EnableInFastMode => true;
        public ModulePermission RequiredPermission => ModulePermission.CoreServices;
        public bool IsCriticalModule => true; // 关键中间件

        public void ConfigureMiddleware(WebApplication app, IConfiguration configuration)
        {
            // 映射控制器路由
            app.MapControllers();
        }

        public void ConfigureMinimalMiddleware(WebApplication app, IConfiguration configuration)
        {
            // 精简路由功能 - 配置基本路由
            app.MapControllers();
        }

        public bool ValidateConfiguration(IConfiguration configuration)
        {
            // 路由中间件无特殊配置要求
            return true;
        }
    }
}
